#include<bits/stdc++.h>
using namespace std;
struct ios{
    inline char gc(){
        static const int IN_LEN=1<<18|1;
        static char buf[IN_LEN],*s,*t;
        return (s==t)&&(t=(s=buf)+fread(buf,1,IN_LEN,stdin)),s==t?-1:*s++;
    }
    template <typename _Tp> inline ios & operator >> (_Tp&x){
        static char ch,sgn; ch = gc(), sgn = 0;
        for(;!isdigit(ch);ch=gc()){if(ch==-1)return *this;sgn|=ch=='-';}
        for(x=0;isdigit(ch);ch=gc())x=x*10+(ch^'0');
        sgn&&(x=-x); return *this;
    }
}io;
#define cin io
struct{
	int w,nxt;
}e[20007];
int idx;
int bgn[10003],du[1500011];
int n,k;
void add(int x,int y)
{
	du[x]++,du[y]++;
	if(n > 10000)
		return;
	e[++idx] = {y,bgn[x]},bgn[x] = idx;
	e[++idx] = {x,bgn[y]},bgn[y] = idx;
}
bool DFS(int p,int S,int f,int dep,int cnt)
{
	cnt += ((S >> p) & 1);
	dep++;
	if(dep == k) return cnt == 1;
	bool res = 1;
	for(int i = bgn[p];i;i = e[i].nxt) if(e[i].w != f)
		res &= DFS(e[i].w,S,p,dep,cnt);
	return res;
}
int main()
{
	freopen("life.in","r",stdin);
	freopen("life.out","w",stdout);
	cin >> n >> k;
	for(int i = 1;i < n;i++)
	{
		int x,y;
		cin >> x >> y;
		add(x,y);
	}
	bool flag = 1;
	for(int i = 1;i <= n;i++)
		flag &= (du[i] <= 2);
	if(flag)
	{
		cout << (min(k,n) ? "YES\n" : "NO\n") << min(k,n);
		return 0;
	}
	int res = 0;
	for(int S = 0;S < (1 << n);S++)
	{
		bool flag = 1;
		for(int i = 1;i <= n;i++)
			flag &= DFS(i,S << 1,0,0,0);
		if(flag)
			res++;
	}
	cout << (res ? "YES\n" : "NO\n") << res;
	return 0;
}